package com.trc202.CS350;
//Term Project Ted Chandler and Daniel Moore
public class Job implements Comparable<Job>{
	public enum Status {WAITING, READY, RUNNING, FINISHED};
	
	private int jobId = 0;
	private int assignedSegmentNum = -1;
	private Status status;
	private int totalExecutionTime = 0;
	private int remainingExecutionTime = 0;
	private int requiredRam = 0;
	
	/**
	 * 
	 * @param jobId Id number of the job
	 * @param totalExecutionTime
	 */
	public Job(int jobId, int totalExecutionTime, int requiredRam){
		this.jobId = jobId;
		this.totalExecutionTime = totalExecutionTime;
		this.remainingExecutionTime = totalExecutionTime;
		this.requiredRam = requiredRam;
		this.status = Status.WAITING;
	}

	public int getJobId() {
		return jobId;
	}

	public void setAssignedSegmentNum(int assignedSegmentNum) {
		this.assignedSegmentNum = assignedSegmentNum;
	}

	public int getAssignedSegmentNum() {
		return assignedSegmentNum;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Status getStatus() {
		return status;
	}

	public int getTotalExecutionTime() {
		return totalExecutionTime;
	}

	public void decrementRemainingExecutionTime() {
		if(!isFinished()){
			remainingExecutionTime = remainingExecutionTime -1;
		}
	}

	public int getRemainingExecutionTime() {
		return remainingExecutionTime;
	}
	
	public boolean isFinished(){
		return remainingExecutionTime < 1;
	}

	public int getRequiredRam() {
		return requiredRam;
	}
	
	@Override
	public String toString(){
		return this.status.toString() + " Time Remain: " + this.remainingExecutionTime;
	}

	@Override
	public int compareTo(Job arg0) {
		return  this.getTotalExecutionTime() - arg0.getTotalExecutionTime();
	}
}
